add codegen-units option to profile section
authorStuart Pernsteiner <spernsteiner@mozilla.com>
Thu, 18 Sep 2014 17:49:43 +0000 (10:49 -0700)
committerStuart Pernsteiner <spernsteiner@mozilla.com>
Thu, 18 Sep 2014 17:49:43 +0000 (10:49 -0700)
src/cargo/core/manifest.rs
src/cargo/ops/cargo_rustc/mod.rs
src/cargo/util/toml.rs

index dc6d27f635ae6323d8b45882dd94377edb8973e5..1b714c5a5e681bb49e9f46d76ed3ac73fde33555 100644 (file)
@@ -107,6 +107,7 @@ pub enum TargetKind {
 pub struct Profile {
     env: String, // compile, test, dev, bench, etc.
     opt_level: uint,
+    codegen_units: Option<uint>,    // None = use rustc default
     debug: bool,
     test: bool,
     doctest: bool,
@@ -121,6 +122,7 @@ impl Profile {
         Profile {
             env: String::new(),
             opt_level: 0,
+            codegen_units: None,
             debug: false,
             test: false,
             doc: false,
@@ -206,6 +208,10 @@ impl Profile {
         self.opt_level
     }
 
+    pub fn get_codegen_units(&self) -> Option<uint> {
+        self.codegen_units
+    }
+
     pub fn get_debug(&self) -> bool {
         self.debug
     }
@@ -223,6 +229,11 @@ impl Profile {
         self
     }
 
+    pub fn codegen_units(mut self, units: Option<uint>) -> Profile {
+        self.codegen_units = units;
+        self
+    }
+
     pub fn debug(mut self, debug: bool) -> Profile {
         self.debug = debug;
         self
@@ -260,6 +271,7 @@ impl<H: hash::Writer> hash::Hash<H> for Profile {
         // to the actual hash of a profile.
         let Profile {
             opt_level,
+            codegen_units,
             debug,
             plugin,
             dest: ref dest,
@@ -273,7 +285,7 @@ impl<H: hash::Writer> hash::Hash<H> for Profile {
             test: _,
             doctest: _,
         } = *self;
-        (opt_level, debug, plugin, dest, harness).hash(into)
+        (opt_level, codegen_units, debug, plugin, dest, harness).hash(into)
     }
 }
 
index a94d93ae1a49f4ff8a4bcf5bd0d40fd2f7836247..40e58cdacd6bc58646c23b356c22e75115e94dc3 100644 (file)
@@ -352,6 +352,11 @@ fn build_base_args(cx: &Context, mut cmd: ProcessBuilder,
         cmd = cmd.arg("--opt-level").arg(profile.get_opt_level().to_string());
     }
 
+    match profile.get_codegen_units() {
+        Some(n) => cmd = cmd.arg("-C").arg(format!("codegen-units={}", n)),
+        None => {},
+    }
+
     if profile.get_debug() {
         cmd = cmd.arg("-g");
     } else {
index ec2e675ff27d57bdf08bfd2f1461f734501a3462..fe5c6c04fcd52391ed9ddc936e01dde80abf7c1d 100644 (file)
@@ -221,6 +221,7 @@ pub struct TomlProfiles {
 #[deriving(Decodable, Clone, Default)]
 pub struct TomlProfile {
     opt_level: Option<uint>,
+    codegen_units: Option<uint>,
     debug: Option<bool>,
 }
 
@@ -604,8 +605,9 @@ fn normalize(libs: &[TomlLibTarget],
             None => return profile,
         };
         let opt_level = toml.opt_level.unwrap_or(profile.get_opt_level());
+        let codegen_units = toml.codegen_units;
         let debug = toml.debug.unwrap_or(profile.get_debug());
-        profile.opt_level(opt_level).debug(debug)
+        profile.opt_level(opt_level).codegen_units(codegen_units).debug(debug)
     }
 
     fn target_profiles(target: &TomlTarget, profiles: &TomlProfiles,